﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Lant.Net.Game;

namespace Lant.Net
{
	public partial class frmMain : Form
	{
		public frmMain()
		{
			InitializeComponent();
		}

		IGame.IGame game = null;
		private void frmMain_Load(object sender, EventArgs e)
		{
			
		}

		private void miGame_Click(object sender, EventArgs e)
		{
			if (game != null)
				if (MessageBox.Show("已经打开了游戏[" + game.GameName + "]，确定要换游戏或重新开始吗？", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.Yes)
					return;
			
			this.Desk.Controls.Clear();
			string gameName = ((MenuItem)sender).Text;
			if (gameName.IndexOf("蚂蚁") >= 0)
				game = new Ant();
			else if (gameName.IndexOf("变色龙") >= 0)
				game = new Dragon();
			else if (gameName.IndexOf("贪吃蛇") >= 0)
				game = new Snake();
			else
			{
				MessageBox.Show(gameName + " 有待开发");
				return;
			}
			UserControl uc = (UserControl)game.Control();
			uc.Location = new Point(0, 0);
			uc.Size = this.Desk.Size;
			this.Desk.Controls.Add(uc);
			this.lblName.Text = game.GameName;
			game.Start();
		}

		private void miGameRule_Click(object sender, EventArgs e)
		{
			string gameRule = "";
			if (game != null)
				gameRule = string.Format("{0} 游戏规则：\r\n\r\n{1}", game.GameName, game.GameRule);
			else
				gameRule = "请选择一款游戏";
			MessageBox.Show(gameRule, "提示");
		}

		private void miQuit_Click(object sender, EventArgs e)
		{
			this.Close();
		}

		private void frmMain_Closing(object sender, CancelEventArgs e)
		{
			if (DialogResult.Yes != MessageBox.Show("确定要退出吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2))
				e.Cancel = true;
		}

		private void miAbout_Click(object sender, EventArgs e)
		{
			MessageBox.Show("小型的游戏大厅，期待(Lant)制作，嘿嘿~~\n\n\r\n  QQ:5466789\r\nMail:cc@xcc.cc","关于");
		}
	}
}